<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>列表</title>
	<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
</head>
<body>
 <h1 class="text-center">管理用户信息</h1>
    <form method="post" action="" class="col-md-4 control-label col-md-offset-5">
      请输入用户名:
      <input type="text" name="key">
      <input type="submit" name='search' value="搜索" class="btn btn-success">
    </form>
<table align="center" class="table table-bordered">
  <tr>
  <th class="text-center">编号</th>
  <th class="text-center">用户名</th>
  <th class="text-center">性别</th>
  <th class="text-center">生日</th>
  <th class="text-center">爱好</th>
  <th class="text-center">学历</th>
  <th class="text-center">自我介绍</th>
  <th width="80" class="text-center">头像</th>
  <th class="text-center">操作<a href="admin.php?c=user&m=form">添加</a></th>
  </tr>
  <?php
  $i=1;
  foreach($data['users'] as $row){
  echo '<tr>';
  echo '<td class="text-center">'.$i++.'</td>';
  // echo '<td class="text-center">'.$row['uid'].'</td>';
  echo '<td class="text-center">'.$row['uname'].'</td>';
  echo '<td class="text-center">'.($row['gender']==0?'男':'女').'</td>';
  echo '<td class="text-center">'.$row['birthdate'].'</td>';
  echo '<td class="text-center">'.$row['hobby'].'</td>';
  switch($row['degree']){
    case '1':$dg="高中";break;
    case '2':$dg="大学";break;
    case '3':$dg="研究生";break;
    case '4':$dg="博士生";break;
    default:$dg="不知道";
  }
  echo '<td class="text-center">'.$dg.'</td>';
  echo '<td class="text-center">'.$row['intro'].'</td>';
  echo '<td align="center"><img class="img-circle" src='."upload/".$row['pic'].' width=80 height=80 alt="无头像" class="img-circle"></td>';
  echo '<td class="text-center"><a href="admin.php?c=user&m=mod&id='.$row['uid'].'" class="btn btn-success" href="#" role="button">修改</a> | <a href="admin.php?c=user&m=del&id='.$row['uid'].'" onClick="return confirm(\'确定要删除吗？\');" class="btn btn-danger" href="#" role="button">删除</a></td>';
  echo '</tr>';
  }
  echo '</table>';
  if($rowsperpage>=$totalrows)
    $totalrows=1;
  else{
    $totalrows=ceil($totalrows/$rowsperpage);
  }
  if($page>1){
    $first="<a href=?key={$key}&page=1>第一页</a>";
    $pre="<a href=?key={$key}&page=".($page-1).">上一页</a>";
  }else{
    $first='首页';
    $pre='上一页';
  }
  if($page<$totalrows){
    $last="<a href=?key={$key}&page=$totalrows>尾页</a>";
    $next="<a href=?key={$key}&page=".($page+1).">下一页</a>";
  }else{
    $last='尾页';
    $next='下一页';
  }
  echo "<table align='center'><tr>";
  echo "<td>$first"."&nbsp;&nbsp;"."$pre"."&nbsp;&nbsp;";
  for($i=1;$i<=$totalrows;$i++){
    echo "<a href='?page=$i&key={$key}'>第{$i}页</a>&nbsp;&nbsp;";
  }
  echo "$next"."&nbsp;&nbsp;"."$lsat &nbsp;";
  echo "<font color=red>";
  echo "&nbsp;&nbsp;第".$page."页/共".$totalrows."页&nbsp;&nbsp;";
  echo "</font></td>";
  ?>
  <td>
  <form method=post action="">
  <input type="hidden" name="key" value=<?php
  if(isset($_GET["key"]))
    echo $_GET["key"];
  ?>>
  <input type="text" name="page" placeholder="页码" size="2">
  <input type="submit" value="转到" class="btn btn-success">
  </form>
  </td>
</table>
</body>
</html>